import request from '@/utils/request'

/**
 * 查询会员套餐列表
 * https://www.showdoc.com.cn/1673866312297516
 * @param {*} data 查询条件
 * @returns
 */
export function productList (data) {
  return request({
    url: '/v1/product/list',
    method: 'post',
    data
  })
}

/**
 * 查看会员套餐数据统计 -- 待定
 * https://www.showdoc.com.cn/1673866312297516
 * @param {*} menuId 套餐ID
 * @returns
 */
export function getMenuStatics (menuId) {
  return request({
    url: '/v1/product/info/' + menuId,
    method: 'get'
  })
}

/**
 * 查看会员套餐营销方案 -- 待定
 * https://www.showdoc.com.cn/1673866312297516
 * @param {*} menuId 套餐ID
 * @returns
 */
export function getMenuPlan (menuId) {
  return request({
    url: '/v1/product/plan/' + menuId,
    method: 'get'
  })
}

/**
 * 新增会员套餐
 * https://www.showdoc.com.cn/1673866312297516
 * @param {*} data
 * @returns
 */
export function addMenu (data) {
  return request({
    url: '/v1/product/create',
    method: 'post',
    data: data
  })
}

/**
 * 修改会员套餐
 * https://www.showdoc.com.cn/1673866312297516
 * @param {*} data
 * @returns
 */
export function updateMenu (data) {
  return request({
    url: '/v1/product/update',
    method: 'put',
    data: data
  })
}

/**
 * 删除会员套餐
 * https://www.showdoc.com.cn/1673866312297516
 * @param {*} menuId 套餐ID
 * @returns
 */
export function delMenu (data, codeObj) {
  return request({
    url: `/v1/product/delete?vcode=${codeObj.code}&vid=${codeObj.vid}`,
    method: 'delete',
    data: data
  })
}

/**
 * 套餐上下架
 * @returns
 */
export function updateStatus (data, codeObj) {
  return request({
    url: `/v1/product/sale?vcode=${codeObj.code}&vid=${codeObj.vid}`,
    method: 'post',
    data
  })
}
/**
 * 发送验证码
 * http://192.168.88.247:4999/web/#/80?page_id=2556
 * @returns
 */
export function sendCode (data) {
  return request({
    url: '/v1/send_code',
    method: 'post',
    data: data
  })
}

/**
 * 优惠券发放
 * @returns
 */
export function providerCouponApi (data, codeObj) {
  return request({
    url: `/api/v1/coupon/provider?vcode=${codeObj.code}&vid=${codeObj.vid}`,
    method: 'post',
    data
  })
}
